[codex] fix desktop context menu zoom positioning#2620
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
76d2a21 to
f2ae3bc
Compare
ApprovabilityVerdict: Approved Targeted bug fix for desktop context menu positioning when zoomed. Adds well-tested utility functions for scaling coordinates/CSS variables by zoom factor, with straightforward mathematical logic and no broader behavioral changes. You can customize Macroscope's approvability policy. Learn more. |
f2ae3bc to
7a7811f
Compare
0b6fbb3 to
c06f7ed
Compare
Dismissing prior approval to re-evaluate c06f7ed
c06f7ed to
412962e
Compare
Dismissing prior approval to re-evaluate 412962e
|
🚀 Expo continuous deployment is ready!
|
What changed
Menu.popupAPI.Why
React mouse events report positions in the web page's zoomed CSS pixel coordinate space, while Electron's native menu popup positioning expects unzoomed window coordinates. When the user zoomed the desktop app out, right-click context menus opened offset from the pointer.
The trash icon also came from a black named native image and did not reliably tint against dark native menus, so the icon now uses Electron's active native theme when the menu template is built.
The sidebar logo/header used a fixed CSS pixel offset to clear the macOS traffic-light buttons. Electron zoom scales that web offset, but the native titlebar buttons do not move. The horizontal titlebar spacing now follows a gentler zoom-out curve so small zoom levels reduce excessive spacing without letting the logo enter the traffic-light area. At very small zoom levels, the wordmark now hides only once its measured rendered width no longer fits in the remaining header slot.
Validation
bun fmtbun lint(passed with existing unrelated warnings)bun typecheckbun run test --filter=@t3tools/desktop -- desktopZoom contextMenuPosition ElectronMenu DesktopWindowNote
Fix desktop context menu zoom positioning and titlebar CSS variable sync
scaleContextMenuPositionForElectronin contextMenuPosition.ts to multiply context menu coordinates by the currentwebFramezoom factor before sending them via IPC, fixing misaligned menus at non-default zoom levels.resolveDesktopZoomCssVariablesin desktopZoom.ts to compute zoom-compensated--desktop-titlebar-heightand--desktop-titlebar-leading-offsetCSS variables.desktop:zoom-factor-changedover a new IPC channel.desktop:zoom-factor-changedwith the current zoom factor onzoom-changedanddid-finish-loadevents.ResizeObserver/resize listener when the header has insufficient horizontal space.Macroscope summarized 412962e.
Note
Low Risk
Desktop UI/preload IPC changes with focused unit tests; no auth, data, or security-sensitive paths.
Overview
Fixes misaligned native context menus when the desktop app is zoomed by scaling popup coordinates from CSS pixels to what Electron expects before IPC (
scaleContextMenuPositionForElectronin preload).Adds zoom-aware macOS sidebar titlebar layout: the main process pushes the current zoom factor via
desktop:zoom-factor-changed; preload sets--desktop-zoom-factor,--desktop-titlebar-height, and--desktop-titlebar-leading-offset(with a gentler zoom-out curve and a traffic-light-safe minimum leading offset). The Electron sidebar header uses those variables instead of fixed52px/90pxpadding.The sidebar wordmark hides (keeps layout space) when measured width no longer fits the header after padding, using
ResizeObserverand viewport resize coalescing.Unit tests cover context-menu scaling and titlebar CSS math.
Reviewed by Cursor Bugbot for commit 412962e. Bugbot is set up for automated code reviews on this repo. Configure here.